#!/bin/bash

# 确保日志目录存在
mkdir -p logs

echo "Starting FastAPI applications..."

# 在后台启动 net 应用
python -m uvicorn net.net_main_nofyrs:app --host 0.0.0.0 --port 9000 > logs/net_app.log 2>&1 &
NET_PID=$!
echo "Net application started with PID $NET_PID on port 9000, logging to logs/net_app.log"

# 在后台启动 laixin 应用
python -m uvicorn laixin.laixin_main:app --host 0.0.0.0 --port 8000 > logs/laixin_app.log 2>&1 &
LAIXIN_PID=$!
echo "Laixin application started with PID $LAIXIN_PID on port 8000, logging to logs/laixin_app.log"

# 等待所有后台进程完成
# 这将使脚本持续运行，直到至少一个后台进程存在
wait $NET_PID $LAIXIN_PID
echo "One or both FastAPI applications have stopped." 